#include <stdio.h>
#include <signal.h>

void sig_quit( int sig )
{
	printf( "Caught SIGQUIT signal.\n" );

	return ;
}


int main( void )
{
	sigset_t newmask, oldmask, pendmask;
	sigset_t wait;

	if ( signal( SIGINT, sig_quit ) == SIG_ERR ) {
		printf( "Cant catch the signal.\n" );
		return -1;
	}
	sigemptyset( &wait );

	sigemptyset( &newmask );
	
	sigaddset( &newmask, SIGINT );

	if ( sigprocmask( SIG_BLOCK, &newmask, &oldmask ) < 0 ) {
		printf( "signal block error.\n" );
		return -1;
	}


	sleep(15);

	
	if ( sigprocmask( SIG_SETMASK, &oldmask, NULL ) < 0 ) {
		printf( "signal block error.\n" );
		return -1;
	}

	if ( sigsuspend( &wait ) != -1 )
		printf( "Sissupend error.\n" );


#if 0
	if ( sigprocmask( SIG_SETMASK, &oldmask, NULL ) < 0 ) {
		printf( "signal block error.\n" );
		return -1;
	}

	if ( sigpending( &pendmask ) < 0 ) {
		printf( "sigquit not pending.\n" );
		return -1;
	}

	if ( sigismember( &pendmask, SIGRTMIN+3 ) )
		printf( "SIGQUIT is pending signal.\n" );

#endif	


	printf( "SIGQUIT is unblock\n" );


	return 0;
}
